package com.ysq.nfd.test;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.HashMap;
import java.util.Map;

import org.jsoup.Connection;
import org.jsoup.Connection.Method;
import org.jsoup.Connection.Response;
import org.jsoup.Jsoup;

/**
 * 微信刷票
 * @author admin
 *
 */
public class BrushVotes {

	
	public static void sendPost(){
		
		String encod = "UTF-8";
		
		String actUrl = "http://mp.weixin.qq.com/mp/newappmsgvote";
		
		int intWxtoken = 1693646479;
		int intQQNumber = 450691871;
		
		for(int i = 0; i<1; i++){
			intWxtoken++;
			String wxtoken = intWxtoken + "";
			
			intQQNumber++;
			String qqNumberStr = intQQNumber + "";
			
			
			String referUrl = "http://mp.weixin.qq.com/mp/newappmsgvote?action=show&__biz=MzA3MDI1NTAyMQ==&supervoteid=619357004&uin=777&key=777"
					+ "&pass_ticket=x5bwYY8ajutTBUp%252FcwGiJg2sYf%252F51bAHUcS%252Fswn3K3gFgQZAaFBXS1DmX9YyAVF6"
					+ "&wxtoken=" + wxtoken + "&mid=2651617809&idx=1";
			
			
			String userAgent = "Mozilla/5.0 (Linux; Android 7.0; MI MAX Build/NRD90M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/53.0.2785.49 "
					+ "Mobile MQQBrowser/6.2 TBS/043305 Safari/537.36 MicroMessenger/6.5.8.1060 NetType/WIFI Language/zh_CN";
			
			/** header **/
			Map<String, String> headerMap = new HashMap<String, String>();
			headerMap.put("Accept", "application/json");
			headerMap.put("Accept-Encoding", "gzip, deflate");
			headerMap.put("Q-UA2", "QV=3&PL=ADR&PR=WX&PP=com.tencent.mm&PPVN=6.5.8&TBSVC=43202&CO=BK&COVC=043305&PB=GE&VE=GA&DE=PHONE&CHID=0&LCID=9422&MO= MIMAX &RL=1080*1920&OS=7.0&API=24");
			headerMap.put("Q-GUID", "4a802534a6987da3feebcf8413b788cb");
			headerMap.put("Q-Auth", "31045b957cf33acf31e40be2f3e71c5217597676a9729f1b");
			headerMap.put("Origin", "http://mp.weixin.qq.com");
			
			//headerMap.put("aaaaaaaaaaa", "aaaaaaaaaa");
			
			/** cookies **/
			Map<String, String> cookieMap = new HashMap<String, String>();
			cookieMap.put("pgv_pvi", "3707998208");
			cookieMap.put("pgv_si", "s3256897536");
			cookieMap.put("ptisp", "cnc");
			cookieMap.put("RK", "Nf3yXOpfWa");
			cookieMap.put("ptcz", "da0d79dfe0539e28ce60cb9eb8e9984f790ed26b0bbc0a50e14b9b100f58a1fb");
			cookieMap.put("pt2gguin", "o0" + qqNumberStr);
			cookieMap.put("sd_userid", "23291492058525820");
			cookieMap.put("sd_cookie_crttime", "1492058525820");
			cookieMap.put("rewardsn", "ab58cc84b1e8564be7f3");
			cookieMap.put("pgv_info", "ssid=s3462705932");
			cookieMap.put("pgv_pvid", "9668385148");
			cookieMap.put("o_cookie", qqNumberStr);
			cookieMap.put("wap_sid", "CLi6ndoJEkBKdmFwV2lhbWFXQ2FPcUprNlBYSFo2c3h2eVE4czVpdGtkYUE0UWc3QkVDMlNZajB0azNQNVhyWGw0RFA5X0c1GAQg/BEoiJrVnQww8vqPyQU=");
			cookieMap.put("wxtokenkey", "d90278bf78067665cba6c4a420bc814421ad9541f8deb14ba7528e7da8b40c48");
			cookieMap.put("wxticket", "3583444155");
			cookieMap.put("wxticketkey", "c7ccf44f4c16a701fb000b1f2045a82c21ad9541f8deb14ba7528e7da8b40c48");
			cookieMap.put("wxuin", "2605145400");
			cookieMap.put("pass_ticket", "x5bwYY8ajutTBUp/cwGiJg2sYf/51bAHUcS/swn3K3gFgQZAaFBXS1DmX9YyAVF6");
			cookieMap.put("wap_sid2", "CLi6ndoJElxMTmhDNWdnVnM1WmVqLTVnc2Y4THVDMkZXdF9NclRmbkpkbzItdHFzNEQ0eDdCamRVYXZ2SUZMMFFIekc5cUh3ZDNLX2VOMjc3Zm1pcmV0N1VoRUJhbzBEQUFBfjDT/JzKBTgNQAE=");
			
			/** parameter **/
			String __biz = "MzA3MDI1NTAyMQ%3D%3D";
			String pass_ticket = "x5bwYY8ajutTBUp%252FcwGiJg2sYf%252F51bAHUcS%252Fswn3K3gFgQZAaFBXS1DmX9YyAVF6";
			String jsonData = "%7B%22super_vote_item%22%3A%5B%7B%22vote_id%22%3A619357005%2C%22item_idx_list%22%3A%7B%22item_idx%22%3A%5B%2216%22%5D%7D%7D%5D%2C%22super_vote_id%22%3A619357004%7D";
			try {
				pass_ticket = URLDecoder.decode(pass_ticket, encod);
				jsonData = URLDecoder.decode(jsonData, "UTF-8");
				__biz = URLDecoder.decode(__biz, "UTF-8");
				
			} catch (UnsupportedEncodingException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
			
			Map<String, String> paramMap = new HashMap<String, String>();
			paramMap.put("action", "vote");
			paramMap.put("__biz", __biz);
			paramMap.put("uin", "777");
			paramMap.put("key", "777");
			paramMap.put("pass_ticket", pass_ticket);
			paramMap.put("f", "json");
			paramMap.put("json", jsonData);
			paramMap.put("idx", "1");
			paramMap.put("mid", "2651617809");
			paramMap.put("wxtoken", wxtoken);
			
			Connection tickCon = Jsoup.connect(actUrl)
					.ignoreContentType(true)
					.method(Method.POST)
					.timeout(10000)
					.userAgent(userAgent)
					.referrer(referUrl)
					.headers(headerMap)
					.cookies(cookieMap)
					.data(paramMap);
					
			try {
				Response response = tickCon.execute();
				
				int statusCode = response.statusCode();
				
				//Document doc = response.parse();
				
				String responseJson = response.body();
				
				System.out.println("[" + statusCode + "]" + responseJson);
				
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		
		}
		
	}
	
	public static void main(String[] args) {
		System.out.println("start ... ");
		
		sendPost();
		
		System.out.println("finished ... ");
	}
	
	
}
